package edu.langnan.xiaoli.controller.common;

import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.core.dto.MomentDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.MomentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cql
 */
@RestController
@RequestMapping("common/moment")
public class CommonMomentController extends BaseController {


    @Autowired
    private MomentService momentService;


    /**
     * 分页获取说说列表
     *
     * @return
     */
    @GetMapping("list")
    public TableDataInfo list() {
        startPage();
        List<MomentDTO> result = momentService.momentList(null);
        return getDataTable(result);
    }

    /**
     * 分页获取某个用户说说列表
     *
     * @return
     */
    @GetMapping("list/{stuId}")
    public TableDataInfo stuOfMomentList(@PathVariable("stuId") Integer stuId) {
        startPage();
        List<MomentDTO> result = momentService.momentList(stuId);
        return getDataTable(result);
    }

}
